﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using OTS.BLL;

public partial class WebControl_NewPro : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        BindNewPro();
    }

    //绑定新品
    private void BindNewPro()
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        ProductBLL productBLL = new ProductBLL();
        DataTable dt = productBLL.GetAllAboutPro();
        string strUrl = "";
        string strImgUrl = "";

        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                switch (i)
                {
                    case 0:
                        sb.Append("<li onmousemove='over(1)' name='p_li'>");
                        sb.Append("<span>1</span>");
                        sb.AppendFormat("<a href='product.aspx?proID={0}'>{1}</a>", dt.Rows[i]["proID"].ToString(), dt.Rows[i]["title"].ToString());
                        sb.Append("<div id='pd1' style='display: block;'>");
                        sb.AppendFormat("<a href='product.aspx?proID={0}'>", dt.Rows[i]["proID"].ToString());
                        strUrl = dt.Rows[i]["bigImg_pic"].ToString().Replace("\\","/");
                        strImgUrl = strUrl.Replace("~/", "");
                        sb.AppendFormat("<img width='170' height='260' src='{0}' />", strImgUrl);
                        sb.Append("</a>");
                        sb.Append("</div>");
                        sb.Append("</li>");
                        break;
                    case 1:
                        sb.Append("<li onmousemove='over(2)' name='p_li'>");
                        sb.Append("<span>2</span>");
                        sb.AppendFormat("<a href='product.aspx?proID={0}'>{1}</a>", dt.Rows[i]["proID"].ToString(), dt.Rows[i]["title"].ToString());
                        sb.Append("<div id='pd2' style='display: none;'>");
                        sb.AppendFormat("<a href='product.aspx?proID={0}'>", dt.Rows[i]["proID"].ToString());
                        strUrl = dt.Rows[i]["bigImg_pic"].ToString().Replace("\\", "/");
                        strImgUrl = strUrl.Replace("~/", "");
                        sb.AppendFormat("<img width='170' height='260' src='{0}' />", strImgUrl);
                        sb.Append("</a>");
                        sb.Append("</div>");
                        sb.Append("</li>");
                        break;
                    case 2:
                        sb.Append("<li onmousemove='over(3)' name='p_li'>");
                        sb.Append("<span>3</span>");
                        sb.AppendFormat("<a href='product.aspx?proID={0}'>{1}</a>", dt.Rows[i]["proID"].ToString(), dt.Rows[i]["title"].ToString());
                        sb.Append("<div id='pd3' style='display: none;'>");
                        sb.AppendFormat("<a href='product.aspx?proID={0}'>", dt.Rows[i]["proID"].ToString());
                        strUrl = dt.Rows[i]["bigImg_pic"].ToString().Replace("\\", "/");
                        strImgUrl = strUrl.Replace("~/", "");
                        sb.AppendFormat("<img width='170' height='260' src='{0}' />", strImgUrl);
                        sb.Append("</a>");
                        sb.Append("</div>");
                        sb.Append("</li>");
                        break;
                    case 3:
                        sb.Append("<li onmousemove='over(4)' name='p_li'>");
                        sb.Append("<span>4</span>");
                        sb.AppendFormat("<a href='product.aspx?proID={0}'>{1}</a>", dt.Rows[i]["proID"].ToString(), dt.Rows[i]["title"].ToString());
                        sb.Append("<div id='pd4' style='display: none;'>");
                        sb.AppendFormat("<a href='product.aspx?proID={0}'>", dt.Rows[i]["proID"].ToString());
                        strUrl = dt.Rows[i]["bigImg_pic"].ToString().Replace("\\", "/");
                        strImgUrl = strUrl.Replace("~/", "");
                        sb.AppendFormat("<img width='170' height='260' src='{0}' />", strImgUrl);
                        sb.Append("</a>");
                        sb.Append("</div>");
                        sb.Append("</li>");
                        break;
                    case 4:
                        sb.Append("<li onmousemove='over(5)' name='p_li'>");
                        sb.Append("<span>5</span>");
                        sb.AppendFormat("<a href='product.aspx?proID={0}'>{1}</a>", dt.Rows[i]["proID"].ToString(), dt.Rows[i]["title"].ToString());
                        sb.Append("<div id='pd5' style='display: none;'>");
                        sb.AppendFormat("<a href='product.aspx?proID={0}'>", dt.Rows[i]["proID"].ToString());
                        strUrl = dt.Rows[i]["bigImg_pic"].ToString().Replace("\\", "/");
                        strImgUrl = strUrl.Replace("~/", "");
                        sb.AppendFormat("<img width='170' height='260' src='{0}' />", strImgUrl);
                        sb.Append("</a>");
                        sb.Append("</div>");
                        sb.Append("</li>");
                        break;
                }
                this.newPro.InnerHtml = sb.ToString();
            }
        }
        else
        {
            this.panelNewPro.Visible = false;
            sb.Append("<label>暂无新品推荐给您</label>");
            this.divMsg.InnerHtml = sb.ToString();
        }
    }
}
